package cn.com.cifi.mars.constant;

/**
 * 版本事件
 * @author Li
 *
 */
public enum VersionEventEnum {
	//【手动新建/编辑保存/手动删除/系统生成/系统刷新/发起审批/作废审批/审批通过/审批未通过】
    MANUALCREATE("manual_create","手动创建"),
    UPDATE_SAVE("update_save","编辑保存"),
    MANUAL_DELETE("manual_delete","手动删除"),
    SYS_GENERATE("sys_generate","系统生成"),
    SYS_REFRESH("sys_refresh","系统刷新"),
    INITIATE_APPROVAL("initiate_approval","发起审批"),
    TO_OA_APPROVED("to_oa_approved","提交到OA审批"),
    TO_VOID_APPROVAL("to_void_approval","作废审批"),
    APPROVAL_ADOPT("approval_adopt","审批通过"),
    APPROVAL_NO_ADOPT("approval_no_adopt","审批未通过")
    
    ;

    private String key;
    private String value;

    VersionEventEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static String getKeyByValue(String key){
        for(VersionEventEnum v:VersionEventEnum.values()){
            if(key.equals(v.getKey())){
                return v.getValue();
            }
        }
        return  null;
    }


    public static String toVersionEvent(Integer eventType) {
        // 事件类型 0:实例已删除 3:流程发起 4:审批通过 5:驳回发起人 6:发起人撤回
        String  versionEvent ="";
        switch (eventType.intValue()) {
            case Constants.ZERO:
                versionEvent = VersionEventEnum.APPROVAL_NO_ADOPT.getKey();
                break;
            case Constants.THREE:
                versionEvent = VersionEventEnum.TO_OA_APPROVED.getKey();
                break;
            case Constants.FOUR:
                versionEvent = VersionEventEnum.APPROVAL_ADOPT.getKey();
                break;
            case Constants.FIVE:
                versionEvent = VersionEventEnum.APPROVAL_NO_ADOPT.getKey();
                break;
            case Constants.SIX:
                versionEvent = VersionEventEnum.APPROVAL_NO_ADOPT.getKey();
                break;
            default:
                break;
        }
        return versionEvent;
    }

}
